Input parametersGravitational acceleration (m/s²) - g = 9.81 ms2 Pendulum length - l = 1 m Pendulum mass - m = 1 kg Initial angle - θ0 = -60 ° = -1.05 rad Maximum simulation time - tmax = 10 s Analytical solution for small rotationsθ ≪ 1 or sin(θ) ≈ θ |
Differential equation - θ″ + gl·θ = 0
Angular frequency - ω = gl·rad = 3.13 rad/s
Cyclic frequency - f = ω2·π·rad = 0.498 Hz
Period - T = 1f = 2.01 s
Equation of motion - θ (t) = θ0·cos (ω·t)
Differential equation - θ″ + gl·sin (θ) = 0
Incomplete elliptic integral of the first kind
F (φ; k) = φ∫0 1 √ 1 − k2·sin (θ) 2 dθ
Jacobi elliptic functions
Modulus - k = sin(θ02) = -0.5
am (u; k) = $Root{F (φ; k) = u; φ ∈ [0; 10·π]}
sn (u; k) = sin (am (u; k) ) , cn (u; k) = cos (am (u; k) )
dn (u; k) = √ 1 − k·sn (u; k) 2 , cd (u; k) = cn (u; k) dn (u; k)
Period - Te = 4· lg·F(π2; k) = 2.15 s
Error - δT = | T − Te |Te = 6.82 %
Cyclic frequency - fe = 1Te = 0.464 Hz
Angular frequency - ωe = 2·π·rad·fe = 2.92 rad/s
Equation of motion - θe (t) = 2·asin(k·cd( gl·t; k))
Energy - E0 = m·l·g· (1 − cos (θ0) ) = 4.9 J
Relative error δT [%] of small displacements period versus initial angle θ0 [°] plot
For that purpose, the II order equation is reduced the following system of I order equations
θ′ = ω and ω′ = gl·sin (-θ)
The solution is performed iteratively
Step size - h = 0.05 s
Number of steps - n = tmaxh = 200
For each time step n = 200 the values for the next step will be obtained by using the following equstions
θn+1 = θn + h·ωn
ωn+1 = ωn + h·gl · sinθn
Allocate vectors
⃗θfwE = vector (n) = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... 0]
⃗ωfwE = vector (n) = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... 0]
⃗EfwE = vector (n) = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... 0]
Set initial conditions
⃗θfwE.1 = θ01 rad = -1.05 , ⃗ωfwE.1 = 0s
Perform Euler steps
Rotation - ⃗θfwE.2 = ⃗θfwE.1 + h·⃗ωfwE.1 = -1.05
Angular velicity - ⃗ωfwE.2 = ⃗ωfwE.1 + h·gl·sin (-⃗θfwE.1) = 0.425 s-1
Energy - ⃗EfwE.1 = m·l2·(12·⃗ωfwE.12 + gl· (1 − cos (⃗θfwE.1) ) ) = 4.9 J
The following iterative procedure is applied:
θn+1 = θn + h·ωn+1
ωn+1 = ωn + h·gl · sinθn+1
Allocate vectors
⃗θbwE = vector (n) = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... 0]
⃗ωbwE = vector (n) = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... 0]
⃗EbwE = vector (n) = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... 0]
Set initial conditions
⃗θbwE.1 = θ01 rad = -1.05 , ⃗ωbwE.1 = 0s
Perform Euler steps
f (θ) = ⃗θbwE.i + h·(⃗ωbwE.i + h·gl·sin (-θ) ) − θ
Rotation - ⃗θbwE.2 = $Root{f (θ) = 0; θ ∈ [-2·π; 2·π]} = -1.03
Angular velicity - ⃗ωbwE.2 = ⃗ωbwE.1 + h·gl·sin (-⃗θbwE.2) = 0.419 s-1
Energy - ⃗EbwE.1 = m·l2·(12·⃗ωbwE.12 + gl· (1 − cos (⃗θbwE.1) ) ) = 4.9 J
The following iterative procedure is applied:
θn+1 = θn + h2 ( ωn + ωn+1 )
ωn+1 = ωn + h·g2·l ( sinθn + sinθn+1 )
Allocate vectors
⃗θCN = vector (n) = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... 0]
⃗ωCN = vector (n) = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... 0]
⃗ECN = vector (n) = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... 0]
Set initial conditions
⃗θCN.1 = θ01 rad = -1.05 , ⃗ωCN.1 = 0s
Perform Euler steps
f (θ) = ⃗θCN.i + h2·(2·⃗ωCN.i + h·g2·l· (sin (-⃗θCN.i) + sin (-θ) ) ) − θ
Rotation - ⃗θCN.2 = $Root{f (θ) = 0; θ ∈ [-2·π; 2·π]} = -1.04
Angular velicity - ⃗ωCN.2 = ⃗ωCN.1 + h·g2·l· (sin (-⃗θCN.1) + sin (-⃗θCN.2) ) = 0.423 s-1
Energy - ⃗ECN.1 = m·l2·(12·⃗ωCN.12 + gl· (1 − cos (⃗θCN.1) ) ) = 4.9 J
The following iterative procedure is applied:
| First step (k₁) - | k1,θ = ωi , | k1,ω = gl·sin (-θi) |
| Second step (k₂) - | k2,θ = ωi + 0.5·h·k1,ω , | k2,ω = gl·sin (- (θi + 0.5·h·k1,θ) ) |
| Third step (k₃) - | k3,θ = ωi + 0.5·h·k2,ω , | k3,ω = gl·sin (- (θi + 0.5·h·k2,θ) ) |
| Fourth step (k₄) - | k4,θ = ωi + h·k3,ω , | k4,ω = gl·sin (- (θi + h·k3,θ) ) |
Update values using weighted averages
θn+1 = θi + h6· (k1,θ + 2·k2,θ + 2·k3,θ + k4,θ)
ωn+1 = ωi + h6· (k1,ω + 2·k2,ω + 2·k3,ω + k4,ω)
Allocate vectors
⃗θRK4 = vector (n) = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... 0]
⃗ωRK4 = vector (n) = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... 0]
⃗ERK4 = vector (n) = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... 0]
Set initial conditions
⃗θRK4.1 = θ01 rad = -1.05 , ⃗ωRK4.1 = 0s
Perform Runge-Kutta 4 steps
RK4 factors
k1,θ = ⃗ωRK4.1 = 0 s-1 , k1,ω = gl·sin (-⃗θRK4.1) = 8.49 s-2
k2,θ = ⃗ωRK4.1 + 0.5·h·k1,ω = 0.212 s-1
k2,ω = gl·sin (- (⃗θRK4.1 + 0.5·h·k1,θ) ) = 8.49 s-2
k3,θ = ⃗ωRK4.1 + 0.5·h·k2,ω = 0.212 s-1
k3,ω = gl·sin (- (⃗θRK4.1 + 0.5·h·k2,θ) ) = 8.47 s-2
k4,θ = ⃗ωRK4.1 + h·k3,ω = 0.423 s-1
k4,ω = gl·sin (- (⃗θRK4.1 + h·k3,θ) ) = 8.44 s-2
Update values using weighted averages
Rotation - ⃗θRK4.2 = ⃗θRK4.1 + h6· (k1,θ + 2·k2,θ + 2·k3,θ + k4,θ) = -1.04
Angular velicity - ⃗ωRK4.2 = ⃗ωRK4.1 + h6· (k1,ω + 2·k2,ω + 2·k3,ω + k4,ω) = 0.424 s-1
Energy - ⃗ERK4.1 = m·l2·(12·⃗ωRK4.12 + gl· (1 − cos (⃗θRK4.1) ) ) = 4.9 J
|
Rotation θ [deg] versus time t [s] plot | ━━━━ Small rotations ━━━━ Large rotations · · · · · Forward Euler ━ ━ ━ Backward Euler ━ · ━ Crank–Nicolson |
Energy E [J] versus time t [s] plot
Rotation θ [deg] versus time t [s] plot
━━━━ Theoretical (large rot.) ━ ━ ━ Crank–Nicolson (IMEX) · · · · · Runge-Kutta 4 (explicit) |
Absolute error Δθ [°] versus time t [s] plot
━━━━ Crank–Nicolson (IMEX) |
Energy E [J] versus time t [s] plot
━━━━ Theoretical (large rot.) ━ ━ ━ Crank–Nicolson (IMEX) · · · · · Runge-Kutta 4 (explicit) |